Skip to content

Fix Ollama API URL normalization by removing trailing slashes #6079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Naam
Copy link

@Naam Naam commented Jul 22, 2025

Related GitHub Issue

Closes: #6078

Roo Code Task Context (Optional)

Description

Ensures consistent behavior when constructing API endpoint URLs by normalizing the base URL to remove any trailing slashes. This prevents issues when the base URL is provided with trailing slashes.

Test Procedure

Added tests to verify URL normalization works correctly with:

  • URLs with a single trailing slash
  • URLs with multiple trailing slashes
  • URLs without trailing slashes

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Does this PR necessitate updates to user-facing documentation?

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs repository).

Additional Notes

Get in Touch


Important

Normalize ollamaBaseUrl in CodeIndexOllamaEmbedder to remove trailing slashes, ensuring consistent API endpoint construction.

  • Behavior:
    • Normalize ollamaBaseUrl in CodeIndexOllamaEmbedder constructor to remove trailing slashes.
    • Ensures consistent API endpoint construction.
  • Tests:
    • Added tests in ollama.spec.ts for URLs with single, multiple, and no trailing slashes.
    • Verifies that API calls use normalized URLs without trailing slashes.

This description was created by Ellipsis for 2f6d6f9. You can customize this summary. It will automatically update as commits are pushed.

Ensures consistent behavior when constructing API endpoint URLs by
normalizing the base URL to remove any trailing slashes. This prevents
issues when the base URL is provided with trailing slashes.

Added tests to verify URL normalization works correctly with:
- URLs with a single trailing slash
- URLs with multiple trailing slashes
- URLs without trailing slashes
@Naam Naam requested review from mrubens, cte and jr as code owners July 22, 2025 20:50
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 22, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 22, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 23, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 23, 2025
Copy link
Collaborator

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Naam! Looks good to me

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 24, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: PR [Needs Review]
Development

Successfully merging this pull request may close these issues.

Ollama URL normalization (leading to issues like #5007) does not clean trailing /
3 participants